package cn.leetcode;

public class Code33 {
    public static void main(String[] args) {

    }

    public int fun(int[] nums, int target) {
        int i = 0;
        int j = nums.length - 1;
        while (i<=j){
            int i1 = (i + j) / 2;
            if(nums[i1] == target){
                return i1;
            }else{
                if (nums[0] <= nums[i1]) {
                    if (nums[0] <= target && target < nums[i1]) {
                        j = i1 - 1;
                    } else {
                        i = i1 + 1;
                    }
                } else {
                    if(target > nums[i1] && target <= nums[j]){
                        i = i1 +1;
                    } else {
                        j = i1 -1;
                    }
                }

            }
        }
        return -1;
    }
}
